Skip to content

embed: link libpython3.<minor>, not the stable ABI stub - #16

Merged
PhilipDeegan merged 3 commits into
masterfrom
embed_libname
Nov 15, 2026
Merged

PhilipDeegan merged 3 commits into
masterfrom
embed_libname

Conversation

@PhilipDeegan

@PhilipDeegan PhilipDeegan commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

With MKN_PYTHON_LIB_EMBED=1, py_libname cut LDLIBRARY at its first dot (since #11), so libpython3.13.so gave -lpython3: the stable ABI stub, which defines none of the API (0 symbols here vs 1677 in libpython3.13.so), so embedding executables fail with undefined Py_Initialize, ...

The name now comes from python's sysconfig: python + LDVERSION (3.13, 3.13t, 3.13d), the library python3-config --embed would link (only sysconfig is used, python3-config is not always installed); without LDVERSION (Windows) python + major and minor (python313).

Tested: an executable embedding python 3.13 links (-lpython3.13) and runs on Linux.

py_libname cut LDLIBRARY at its first dot: libpython3.13.so gave -lpython3, the stable ABI
stub, whose symbols the linker does not resolve through it (undefined Py_Initialize etc.
with MKN_PYTHON_LIB_EMBED). Strip only the lib prefix and the library suffix.
@PhilipDeegan
PhilipDeegan merged commit ce803be into master Nov 15, 2026
3 checks passed
@PhilipDeegan
PhilipDeegan deleted the embed_libname branch November 15, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant